//////////////////////////////////////////////////////////////////////////////////
//
//	TK Subtract Kills
//		- Version 1.2
//		- 12.25.2006
//		- diamond-optic
//
//////////////////////////////////////////////////////////////////////////////////
//
// Information:
//
// 	- When someone TKs, they will lose kills...
//
// CVARS: 
//
//	  amx_tk_subtract_kills "1"	//Turn ON(1)/OFF(0)
//
//	  amx_tk_subtract_num "5"	//Number of kills to subtract
//
//	  amx_tk_subtract_msg "1"	//Message Mode
//						//"0" = No Message
//						//"1" = Chat Message
//						//"2" = Center Message
//						//"3" = Hud Message
//
//	  amx_tk_subtract_msg_who "1"	//Who will see the messages
//						//"0" = No One
//						//"1" = Everyone
//						//"2" = TKer Only
//
// Extra:
//
//	- Just a very simple plugin made for a request on IRC
//
// Changelog:
//
//	 - 06.24.2006 Version 1.0
//		Initial Release
//
//	 - 06.25.2006 Version 1.1
//		Added Messages
//
//	 - 12.25.2006 Version 1.2
//		fixed an error with the native
//		added public cvar for tracking
//
//////////////////////////////////////////////////////////////////////////////////

#include <amxmodx>
#include <fun>

new p_number, p_on, p_msg_type, p_msg_who

public plugin_init()
{
	register_plugin("TK Subtract Kills","1.2","diamond-optic")
	
	register_cvar("amx_tk_subtract_kills_stats", "1.2", FCVAR_SERVER|FCVAR_SPONLY)
	
	register_event("DeathMsg","funcDeath","a")
	
	p_on = register_cvar("amx_tk_subtract_kills", "1")
	p_number = register_cvar("amx_tk_subtract_num", "5")
	p_msg_type = register_cvar("amx_tk_subtract_msg", "1")
	p_msg_who = register_cvar("amx_tk_subtract_msg_who", "1")
}

public funcDeath()
{
	new killer = read_data(1)
	new victim = read_data(2)
	
	if(!is_user_connected(killer) || get_pcvar_num(p_on) != 1)
		return PLUGIN_HANDLED
	
	if(killer && (killer!=victim) && (get_user_team(killer)==get_user_team(victim)))
		{
		set_user_frags(killer, get_user_frags(killer)-get_pcvar_num(p_number))
		
		new killer_name[33], victim_name[33]
		
		get_user_name(killer,killer_name,32)
		get_user_name(victim,victim_name,32)
		
		if(get_pcvar_num(p_msg_type) == 1)		//chat
			{
			if(get_pcvar_num(p_msg_who) == 1)	//all
				{
				client_print(0,print_chat,"* %s has lost %d kills for TKing %s *",killer_name,get_pcvar_num(p_number),victim_name)
				}
			else if(get_pcvar_num(p_msg_who) == 2)	//killer
				{
				client_print(killer,print_chat,"* You have lost %d kills for TKing %s *",get_pcvar_num(p_number),victim_name)
				}
			}
		else if(get_pcvar_num(p_msg_type) == 2)		//center
			{
			if(get_pcvar_num(p_msg_who) == 1)	//all
				{
				client_print(0,print_center,"* %s has lost %d kills for TKing %s *",killer_name,get_pcvar_num(p_number),victim_name)
				}
			else if(get_pcvar_num(p_msg_who) == 2)	//killer
				{
				client_print(killer,print_center,"* You have lost %d kills for TKing %s *",get_pcvar_num(p_number),victim_name)
				}
			}
		else if(get_pcvar_num(p_msg_type) == 3)		//hud
			{
			if(get_pcvar_num(p_msg_who) == 1)	//all
				{
				set_hudmessage(random_num(0,255), random_num(0,255), random_num(0,255), 0.01, 0.70, 0, 0.0, 3.0, 0.0, 0.0, 4)
				show_hudmessage(0, "* %s has lost %d kills for TKing %s *",killer_name,get_pcvar_num(p_number),victim_name)
				}
			else if(get_pcvar_num(p_msg_who) == 2)	//killer
				{
				set_hudmessage(random_num(0,255), random_num(0,255), random_num(0,255), 0.01, 0.70, 0, 0.0, 3.0, 0.0, 0.0, 4)
				show_hudmessage(killer, "* You have lost %d kills for TKing %s *",get_pcvar_num(p_number),victim_name)
				}
			}
		}
	return PLUGIN_CONTINUE
}
